package com.xiaoke.liantongdemo.widget;

import java.util.ArrayList;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.ScrollView;

import com.xiaoke.liantongdemo.bean.BusinessInput;
import com.xiaoke.liantongdemo.bean.BusinessInputs;
import com.xiaoke.liantongdemo.bean.BusinessPage;

public class BusinessInputsLayout extends ScrollView {
	
	private Context context;
	private BusinessInputs businessInputs;
	
	private LinearLayout mainLayout;

	public BusinessInputsLayout(Context context, BusinessInputs businessInputs) {
		super(context);
		this.context = context;
		this.businessInputs = businessInputs;
		init();
	}
	
	private void init(){
		mainLayout = new LinearLayout(context);
		mainLayout.setOrientation(LinearLayout.VERTICAL);
		addView(mainLayout);
		ArrayList<BusinessPage> businessPageList = businessInputs.getBusinessPageList();
		for(BusinessPage businessPage : businessPageList){
			ArrayList<BusinessInput> businessInputList = businessPage.getBusinessInputList();
			for(BusinessInput businessInput : businessInputList){
				BusinessInputLayout businessInputLayout = new BusinessInputLayout(context, businessInput);
				mainLayout.addView(businessInputLayout);
				businessInput.setBusinessInputLayout(businessInputLayout);
			}
		}
	}
	
	public BusinessInputs getInputedBusinessInputs(){
		ArrayList<BusinessPage> businessPageList = businessInputs.getBusinessPageList();
		for(BusinessPage businessPage : businessPageList){
			ArrayList<BusinessInput> businessInputList = businessPage.getBusinessInputList();
			for(BusinessInput businessInput : businessInputList){
				BusinessInputLayout businessInputLayout = businessInput.getBusinessInputLayout();
				businessInput.setInput(businessInputLayout.getInput());
			}
		}
		return businessInputs;
		
	}

}
